package team.seekers.hula.course.structure.notice.service;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.seekers.hula.course.structure.notice.dao.CourseNoticeDao;
import team.seekers.hula.course.structure.notice.entity.dao.CourseNoticeDO;
import team.seekers.hula.course.structure.notice.entity.dto.CourseNoticeDTO;

import java.util.ArrayList;
import java.util.List;

@Service
public class CourseNoticeService {

    @Autowired
    private CourseNoticeDao courseNoticeDao;


    /**
     * 查询课程公告
     */
    public List<CourseNoticeDTO> queryNoticeByCourseId(String courseId) {
        List<CourseNoticeDO> courseNoticeDOS = courseNoticeDao.lambdaQuery().eq(CourseNoticeDO::getCourseId, courseId).list();
        ArrayList<CourseNoticeDTO> courseNoticeDTOS = new ArrayList<>();
        for (CourseNoticeDO courseNoticeDO : courseNoticeDOS) {
            CourseNoticeDTO courseNoticeDTO = new CourseNoticeDTO();
            BeanUtils.copyProperties(courseNoticeDO,courseNoticeDTO);
            courseNoticeDTOS.add(courseNoticeDTO);
        }
        return courseNoticeDTOS;
    }

}
